﻿using SuperMoney.Datas;
using SuperMoney.Datas.DbModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SuperMoney
{
	public class DeviceAccountService
	{
		public static readonly DeviceAccountService Instance = new DeviceAccountService();

		public DeviceAccount GetOrCreate(string deviceId, string device)
		{
			var deviceAccount = DeviceAccountDbService.Instance.Get(deviceId);
			if (deviceAccount == null)
			{
				deviceAccount = DeviceAccountDbService.Instance.Create(deviceId, 0, device);
			}
			return deviceAccount;
		}

		/// <summary>
		/// 获取设备账户信息。
		/// </summary>
		/// <param name="deviceId">设备编号。</param>
		/// <returns></returns>
		public DeviceAccount Get(string deviceId)
		{
			return DeviceAccountDbService.Instance.Get(deviceId);
		}

		/// <summary>
		/// 设备账号是否存在。
		/// </summary>
		/// <param name="deviceId">设备编号。</param>
		/// <returns></returns>
		public bool Exists(string deviceId)
		{
			return DeviceAccountService.Instance.Exists(deviceId);
		}
	}
}
